#include "HUDtimer.h"
#include "Transformation.h"
#include "SimpleText.h"
#include "Scene.h"
#include "Counter.h"
#include "MainCounterState.h"

using namespace game_engine;
using namespace game_engine::library;
using namespace game_engine::components;
using namespace game_engine::open_gl;
using namespace game_engine::utils;

///////////////////////////////////////////////////////////////////////////////
// Constructors and Destructors
///////////////////////////////////////////////////////////////////////////////

HUDtimer::HUDtimer(void)
    : GameObject()
{
}

HUDtimer::HUDtimer(Scene *scn, const string &n, const string &t, 
    const DrawLevelType d)
    : GameObject(scn, n, t, d)
{
    // Create its components
    Transformation *timerTransf = new Transformation(this, 0.0, 0.0, 
        0.0, 0.0, 1.0, 1.0);
    SimpleText *timerText = new SimpleText(this, HELVETICA_18, 
        ColorRGB(255.0, 255.0, 255.0));
    Counter *counter = new Counter(this);

    // Add components to object
    addComponent(timerTransf);
    addComponent(timerText);
    addComponent(counter);
}

HUDtimer::~HUDtimer(void)
{
}

///////////////////////////////////////////////////////////////////////////////
// Getters
///////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////////////////////////////
// Setters
///////////////////////////////////////////////////////////////////////////////

void HUDtimer::setMode(const TimerMode &m)
{
    // Get the Counter component
    Counter *counter = dynamic_cast<Counter*> (getComponent("Counter"));
    counter->setMode(m);
}

void HUDtimer::setValue(const FLOAT32 val)
{
    // Get the Counter component
    Counter *counter = dynamic_cast<Counter*> (getComponent("Counter"));
    counter->setValue(val);
}

void HUDtimer::setPosition(const Point &pos)
{
    // Get the Transformation component
    Transformation *transf = dynamic_cast<Transformation*> 
		(getComponent("Transformation"));
    transf->setPosition(pos);
}

void HUDtimer::setTextFont(const open_gl::FontType &f)
{
    // Get the SimpleText component
    SimpleText *txt = dynamic_cast<SimpleText*> (getComponent("SimpleText"));
	txt->setFontType(f);
}

void HUDtimer::setTextColor(const utils::ColorRGB &c)
{
    // Get the SimpleText component
    SimpleText *txt = dynamic_cast<SimpleText*> (getComponent("SimpleText"));
	txt->setColor(c);
}

